<template>
  <div class="layout-container">
    <el-container>
      <el-aside width="200px">
        <el-menu
          :default-active="$route.path"
          router
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b">
          <el-menu-item index="/dashboard">
            <i class="el-icon-s-data"></i>
            <span>仪表盘</span>
          </el-menu-item>
          <el-menu-item index="/store">
            <i class="el-icon-office-building"></i>
            <span>门店管理</span>
          </el-menu-item>
          <el-menu-item index="/banner">
            <i class="el-icon-picture"></i>
            <span>轮播图管理</span>
          </el-menu-item>
          <el-menu-item index="/user">
            <i class="el-icon-user"></i>
            <span>用户管理</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-container>
        <el-header>
          <div class="header-right">
            <el-dropdown>
              <span class="el-dropdown-link">
                <i class="el-icon-user"></i>
                {{ username }}
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: '管理员'
    }
  },
  methods: {
    logout() {
      localStorage.removeItem('token')
      this.$router.push('/login')
    }
  }
}
</script>

<style scoped>
.layout-container {
  height: 100%;
}
.el-container {
  height: 100%;
}
.el-header {
  background: #fff;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  height: 60px;
}
.el-aside {
  background: #545c64;
  height: 100%;
}
.el-main {
  padding: 20px;
  height: calc(100% - 60px);
}
</style>